<template>
  <q-btn unelevated
         @click="logout">
    <q-icon name="logout" />
  </q-btn>
</template>

<script setup>

import { authStore } from "stores/auth-store";
import { ref } from "vue";
import { useRouter } from "vue-router";

defineOptions({
  name: 'LogOutButton'
});

const auth = authStore()
const isLoading = ref(false)
const router = useRouter()

const logout = async () => {
  isLoading.value = true
  try {
    auth.logout()
    console.log('asdasd')
    await router.push({ path: '/auth/login' })
  } catch (err) {
    console.error(err)
  }
}

</script>

<style scoped lang="scss">

</style>
